package com.yc.shopping.dao;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import com.yc.shopping.util.DBHelper;

public class GoodTypeDao {
	
	/**
	 * 查看所有商品类型
	 * @return
	 * @throws SQLException
	 */
	public List<Map<String , Object>> findAll() throws SQLException{
		String sql = " select * from tb_goodtype ";
		return DBHelper.selectListMap(sql);
		
	}
	/**
	 * 添加商品类型
	 * @param name
	 * @return
	 * @throws SQLException
	 */
	public int add (String name) throws SQLException {
		String sql = "insert into tb_goodtype values(?,?,1)";
		Integer tid=Integer.valueOf(DBHelper.selectOneMap("select max(tid) mtid from tb_goodtype").get("MTID").toString()) ;
		
		return DBHelper.update(sql, tid+1,name);
		
	}
	
	
}
